<!doctype html>
<html>
<head>
	<meta http-equiv="content-type" content="text/html;charset=utf-8">
	<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
<style>
body {
  min-width:250px;
  #overflow-x:hidden;
}
</style>
<script type="text/javascript" src="http://weixiao001.com/js/weixiao.js"></script>

<script>

var weblist = weixiao.merchant_list;

function drawList(filter) {
    $('#weblist').empty();
    if(!filter) filter = ',';
    for(web in weblist) {
        if(weblist[web].keywords.indexOf(filter)!=-1)
            $('#weblist').append('<span><a href=\"'+weblist[web].url+'\" target=\"_blank\">'+weblist[web].name+'</a></span><br />');
    }
    $('#weblist span:first').css('bgcolor','#00ff00');
}


function reloadList() {
  var filter = $("#filter").val();
  
  drawList(filter);
}

var ENTER_KEY = 13;
window.onkeydown = function(event) {
  if (event.keyCode == ENTER_KEY) {
    var url = $('#weblist span a:first').attr('href');
    window.open (url, 'newwindow');
  }
}

function on_inited(){
	reloadList();
	if(weixiao.has_login()) {
		$('#user').append('欢迎笑友，'+weixiao.get_user().display_name);
	}
	else {
		$('#user').append('匿名笑友，请到<a href="http://weixiao001.com/" target="_blank">微笑网登录</a>');
	}
}

function onload() {
    $("#filter").focus();
	chrome.cookies.get(
			{
				'url':'http://weixiao001.com/',
				'name':'user_token'
			},
			function(cookie){
				if(cookie) weixiao.init(on_inited, cookie.value);
				else weixiao.init(on_inited);
			}
			);
}

</script>
</head>

<body onload="onload()">
<div id='user'></div>
输入网址/名称/简拼，按回车<br/>
<div id="filter_div">
<input id="filter" type="text" size="33" oninput="reloadList()">
</div>
<div id="weblist">
</div>

</body>
</html>
